<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('下载文件')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-project-edit" th:object="${thesisMapping}">
        <input name="tmId" th:field="*{tmId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">文件路径：</label>
            <div class="col-sm-8">
                <input id="project_url" name="project_url" class="form-control" type="file">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = ctx + "thesis/project";
    $("#form-project-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            uploadFile();

        }
    }
    function uploadFile() {
        var formData = new FormData();
        if ($('#project_url')[0].files[0] == null) {
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
        formData.append('tmId', $('#tmId').val());
        formData.append('file', $('#project_url')[0].files[0]);
        $.ajax({


            url: prefix + "/edit",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function (result) {
                $.operate.successCallback(result);
            }
        });
    }
</script>
</body>
</html>